/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

/**
 *
 * @author ceci torres
 */
import java.sql.*;

public class conexion {

//atributos   
    private String bd = "aplicacion_web";
    private String login = "root";
    private String password = "jellybeans009";
    private String url = "jdbc:mysql://localhost/" + bd;
    Connection canal = null;

//contructor    
    public conexion() {

        try {
            Class.forName("com.mysql.jdbc.Driver");
            canal = DriverManager.getConnection(url, login, password);
        } catch (java.lang.ClassNotFoundException e) {
        } catch (SQLException e) {
        };

    }
//metodos  

    public Connection getConnection() {
        return canal;
    }

    public void desconectar() {
        canal = null;
    }
    
    public void registerUser(String email, String pass, String rpass, String realname, String nick, String gender, int age, float weight, float height){
        String sql = "INSERT INTO registro VALUES(NULL,'" + realname + "','" + nick + "','" + pass + "','" + age + "','" + gender + "','" + weight + "','" + height + "','" + email + "')";
        PreparedStatement ps = canal.prepareStatement(sql);
        ps.executeUpdate();
        
        try {
                instruccion.executeUpdate("INSERT INTO registro VALUES(NULL,'" + realname + "','" + nick + "','" + pass + "','" + age + "','" + gender + "','" + weight + "','" + height + "','" + email + "')");
                instruccion.close();
            } catch (SQLException e) {
                out.println(e);
            };
            out.println("Registro exitoso");
    }
}
